package com.xwx.common.interceptor;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.kit.PropKit;
import com.xwx.common.model.LoginLogModel;

/**
* @Description:登录日志拦截,需在登录验证方法上增加该拦截器
* @author:Dream QQ:68697015
* @time:2015年8月17日 下午4:59:13
 */
public class LoginLogInterceptor implements Interceptor{
	@Override
	public void intercept(Invocation inv) {
		inv.invoke();
		LoginLogModel llm = new LoginLogModel();
		llm.set("descption", "登录失败");
		Controller c = inv.getController();
		llm.set("loginId", c.getPara("loginId"));
		llm.set("ip", c.getRequest().getRemoteHost());
		llm.set("ua", c.getRequest().getHeader("user-agent"));
		if(c.getSessionAttr(PropKit.get("sessionUserKey"))!=null)llm.set("descption", "登录成功");
		llm.save();
	}

}
